//
//  DKAuthHomeProductCell.m
//  DanKU
//
//  Created by 吴斌 on 2023/11/9.
//

#import "DKAuthHomeProductCell.h"
#import "DKAuthHomeNullProductView.h"
#import "DKAuthHomeProductView.h"
static NSString * DKAuthHomeProductCellId = @"DKAuthHomeProductCellId";
@interface DKAuthHomeProductCell()
@property (nonatomic,strong) DKAuthHomeNullProductView *dk_AuthHomeNullProductView;
@property (nonatomic,strong) DKAuthHomeProductView *dk_AuthHomeProductView;
@end
@implementation DKAuthHomeProductCell
+ (instancetype)authHomeProductCell:(UITableView *)tableView{
    DKAuthHomeProductCell * dk_AuthHomeProductCell = [tableView dequeueReusableCellWithIdentifier:DKAuthHomeProductCellId];
    if (!dk_AuthHomeProductCell) {
        dk_AuthHomeProductCell = [[DKAuthHomeProductCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DKAuthHomeProductCellId];
    }
    dk_AuthHomeProductCell.backgroundColor = [UIColor clearColor];
    dk_AuthHomeProductCell.selectionStyle = UITableViewCellSelectionStyleNone;
    dk_AuthHomeProductCell.accessoryType = UITableViewCellAccessoryNone;
    return dk_AuthHomeProductCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    WeakSelf(self)
    self.dk_AuthHomeNullProductView = [[DKAuthHomeNullProductView alloc] init];
    [self addSubview:self.dk_AuthHomeNullProductView];
    [self.dk_AuthHomeNullProductView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.top.equalTo(@(DK_IsWidthScale(20)));
        make.height.equalTo(@(DK_IsWidthScale(129)));
    }];
    self.dk_AuthHomeProductView = [[DKAuthHomeProductView alloc] init];
    self.dk_AuthHomeProductView.hidden = YES;
    [self.contentView addSubview:self.dk_AuthHomeProductView];
    [self.dk_AuthHomeProductView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(-DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
    self.dk_AuthHomeProductView.SelectSigleProductBlock = ^(DKUserProductPackageModel * _Nonnull dk_UserProductPackageMdl) {
        if(weakSelf.SelectSigleProductBlock){
            weakSelf.SelectSigleProductBlock(dk_UserProductPackageMdl);
        }
    };
    self.dk_AuthHomeProductView.SelectProductBlock = ^(NSArray * _Nonnull selectProductList) {
        if(weakSelf.SelectProductBlock){
            weakSelf.SelectProductBlock(selectProductList);
        }
    };
}
-(void)setSelectProductList:(NSArray *)selectProductList{
    _selectProductList = selectProductList;
    if(_selectProductList.count > 0){
        self.dk_AuthHomeNullProductView.hidden = YES;
        self.dk_AuthHomeProductView.hidden = NO;
        self.dk_AuthHomeProductView.dk_UserProductPackMdl = _dk_UserProductPackMdl;
        self.dk_AuthHomeProductView.selectProductList = _selectProductList;
    }else{
        self.dk_AuthHomeNullProductView.hidden = NO;
        self.dk_AuthHomeProductView.hidden = YES;
    }
}
@end
